Skip to content

perf(markdown): cache completed streaming blocks#7305

Closed
c121914yu wants to merge 2 commits into
labring:mainfrom
c121914yu:codex/chatbox-stream-tail-fade
Closed

perf(markdown): cache completed streaming blocks#7305
c121914yu wants to merge 2 commits into
labring:mainfrom
c121914yu:codex/chatbox-stream-tail-fade

Conversation

@c121914yu

Copy link
Copy Markdown
Collaborator

Summary

  • split streaming Markdown into root-level blocks and memoize completed blocks
  • keep the existing tail-only fade on the active block
  • preserve cross-block reference links and GFM footnotes by falling back to full-document rendering

Verification

  • pnpm exec vitest run -c vitest.config.ts test/components/Markdown/streamMarkdownBlocks.test.ts test/components/Markdown/rehypeStreamAnimated.test.ts test/components/Markdown/utils.test.ts --run --coverage=false
  • app test suite: 150 test files passed; the 8 initial sandbox-adapter resolution failures passed after building the local workspace package
  • targeted ESLint and Prettier checks passed

No documentation changes.

Copilot AI review requested due to automatic review settings July 14, 2026 13:00
@c121914yu

Copy link
Copy Markdown
Collaborator Author

Superseded by clean cache-only PR #7306 based on latest main.

@c121914yu c121914yu closed this Jul 14, 2026
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 18.43% 1632 / 8855
🔵 Statements 18.41% 1713 / 9300
🔵 Functions 16.21% 342 / 2109
🔵 Branches 15.1% 759 / 5024
File CoverageNo changed files found.
Generated in workflow #1406 for commit 106bb4d by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown

Admin Preview Image Ready!

ghcr.io/labring/fastgpt-pr:admin_106bb4d9bb0773e3f271b275bbd04772c85fa2e8

🕒 Time: 2026-07-14 21:10:37 (UTC+8)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves streaming Markdown rendering performance in the app by splitting the streamed Markdown into root-level blocks and memoizing completed blocks so only the actively-growing tail block re-renders (while preserving cross-block reference/footnote correctness via a full-document fallback).

Changes:

  • Added a unified/remark-based splitMarkdownBlocks helper to split Markdown by root node source ranges and detect reference/footnote cases that require full-document rendering.
  • Updated the Markdown renderer to render per-block ReactMarkdown instances via a memoized MarkdownStreamBlock, applying the streaming tail animation only to the active (last) block.
  • Updated the stream-tail fade-in behavior and CSS fallback, and added unit tests covering splitting behavior and rendering equivalence.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/app/test/components/Markdown/streamMarkdownBlocks.test.ts Adds coverage for block splitting behavior, offsets, reference/footnote fallback, and render equivalence.
projects/app/src/components/Markdown/streamMarkdownBlocks.ts Introduces root-level Markdown block splitting using unified + remark-parse (+ math/gfm) with safe fallbacks.
projects/app/src/components/Markdown/index.tsx Switches streaming rendering to memoized per-block rendering; keeps tail-only animation on the last block.
projects/app/src/components/Markdown/index.module.scss Adds CSS keyframes/props to provide a fade-in fallback for .stream-tail.
projects/app/package.json Adds direct dependencies needed for block parsing (remark-parse, unified).
pnpm-lock.yaml Locks newly added dependencies for the app workspace.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants